    subroutine read_Di_Bona_Law(DBNet,NewNet)
    USE IFPORT
    USE PARSE_CSV    
    include 'DiBonaNet_structure.FI' ! commento
    
    character*80 fil,line
    logical success
    integer istart,iend,len,ich,i,ier,i1,i2
    character*1 sep
    data sep/','/

    write(*,*)' subroutine: read_Di_Bona_Law'
    is=0
! open the Di Bona magnitude-correction-and-station-file
    success=systemqq(' dir  ')  
 !!!   1 write(*,*)' please insert a Bi Bona station file name:'
 !!!   read(*,'(a)',err=1)fil
    
    fil ='ItalianMLScale_111005.txt'
    open(status='old',readonly,unit=1,file=fil,err=99)
  
    2 read(1,'(q,a)',end=9)len,line
      if(line(1:1).eq.'#')then
! it is only a comment
         goto 2
      else if(line(1:6).eq.'params' .or. line(1:6).eq.'PARAMS' )then
! 3 parameters for the general attenuation law
         read(line(7:len),*) dbnet.r1, dbnet.r2, dbnet.r3
         write(*,*)' r1 ',dbnet.r1,'  r2 ',dbnet.r2,'  r3 ',dbnet.r3 
      else 
! read a station correction and its error.
       is=is+1
       i1=1
       dbnet.sta(is).code=' '
       call parse_csv_var(sep,ier,line,i1,i2,len,dbnet.sta(is).code ,ich)    
       call parse_csv_var(sep,ier,line,i1,i2,len,dbnet.sta(is).SC)    
       call parse_csv_var(sep,ier,line,i1,i2,len,dbnet.sta(is).SCerr)    

       write(*,'(3x,i5,3x,a5,3x,f8.3)')is,dbnet.sta(is).code,dbnet.sta(is).SC
    endif
    goto 2
    9  dbnet.nsta=is
    write(*,*)' end of file. I have read ',dbnet.nsta,' stations'
    write(*,*)' Parameters are: ',dbnet.r1,dbnet.r2,dbnet.r3
    
    NewNet = dbnet
    ! initialize a No-Correcion-Network NewNet
    do i=NewNet.nsta+1,1000
       NewNet.sta(i).sc = 0.0
       NewNet.sta(i).code = '     '
       NewNet.sta(i).scerr  = 0.0
       NewNet.sta(i).n_data = 0
       NewNet.sta(i).mean_dev  = 0.0
       NewNet.sta(i).wgt_mean_dev  = 0.0
       NewNet.sta(i).median_dev  = 0.0
       NewNet.sta(i).huber_dev  = 0.0
    enddo
    
    return
    99 write(*,*)' error in opening file ',fil
    pause
    stop
    end
    
    